class_name LogicalEffectBase
extends Node2D

#region 属性
@export var effect_name:String
@export var trigger_type:GameEnum.LogicalEffectTriggerType
@export var condition_logical_effects:Array[LogicalEffectBase] = []
var manager:LogicalEffectComponent
var active_state:bool = false
var life_state:bool = true
var is_completed:bool = false
var sub_items:Array = []
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
func init_effect(manager:LogicalEffectComponent):
	self.manager = manager
## 应用
func apply():
	active_state = true
## 移除
func remove():
	active_state = false
	destroy_all_sub_items()
## 更新
func update():
	pass
## 刷新
func refresh():
	pass
## 完成
func complete():
	active_state = true
	is_completed = true
	destroy_all_sub_items()
func can_trigger() -> bool:
	if condition_logical_effects.size() == 0:
		return true
	match trigger_type:
		GameEnum.LogicalEffectTriggerType.Manual:
			return active_state
		GameEnum.LogicalEffectTriggerType.All:
			return condition_logical_effects.all(func (x):return not x.is_completed)
		GameEnum.LogicalEffectTriggerType.Any:
			return condition_logical_effects.any(func (x):return not x.is_completed)
		_:
			return false
func get_life_state() -> bool:
	return life_state
func set_life_state(state):
	life_state = state
func add_sub_item(item):
	sub_items.append(item)
func destroy_all_sub_items():
	for item in sub_items:
		if item:
			item.queue_free()
#endregion
#region 私有方法
#endregion
#region 生命周期函数
#endregion
